
(use-package advance-words-count
  :load-path "site-lisp"
  :bind
  (("C-c C" . advance-words-count)))

;; -------- auto-save --------
(use-package auto-save
  :load-path "lazycat-bucket/auto-save"
  ;; :init
  ;; (setq auto-save-idle 3)
  :config
  (auto-save-enable)
  (setq auto-save-slient t
	    auto-save-delete-trailing-whitespace t)
  (setq auto-save-disable-predicates
        '((lambda ()
            (string-suffix-p
             "gpg"
             (file-name-extension (buffer-name)) t)))))

;; -------- wrap lines based on characters --------
;; (use-package flywrap
;;   ;; github: casouri/lunarymacs/blob/master/site-lisp/flywrap.el
;;   :load-path "site-lisp"
;;   :config
;;   (flywrap-mode))

;; -------- visual version of `align-regexp' command --------
(use-package ialign
  :ensure t
  :config
  (global-set-key (kbd "C-x l") #'ialign))

;; -------- Eclipse-like moving and duplicating lines or rectangles --------
(use-package move-dup
  :bind
  (("<M-up>"   . move-dup-move-lines-up)
   ("C-M-p"    . move-dup-duplicate-up)
   ("<M-down>" . move-dup-move-lines-down)
   ("C-M-n"    . move-dup-duplicate-down)))

;; -------- use thing-edit to cut/copy quickly --------
(use-package thing-edit
  :load-path "lazycat-bucket/thing-edit"
  :config
  (defun p1uxtar-awesome-pair-copy ()
    "Combine `awesome-pair-kill' & `yank' to instead `thing-copy-to-line-end'."
    (interactive)
    (let ((pt (point)))
      (awesome-pair-kill)
      (yank)
      (goto-char pt)))
  :bind
  (("M-'" . thing-copy-parentheses)
   ("M-k" . p1uxtar-awesome-pair-copy)
   ("C-M-w" . thing-copy-whole-buffer)
   ("C-S-y" . thing-replace-symbol)
   ("C-w" . thing-cut-symbol)
   ("M-w" . thing-copy-symbol)))

;; -------- map functions when selected (`region-active-p') --------
(use-package selected
  :ensure t
  :after thing-edit
  :diminish selected-minor-mode
  :commands selected-minor-mode
  :init
  (selected-global-mode)
  :bind
  (:map selected-keymap
        (("C-w" . thing-cut-region-or-line)
         ("M-w" . thing-copy-region-or-line))))

;; -------- Edit comment/string/docstring/code block --------
;; in separate buffer with specific mode.
(use-package separedit
  :ensure t
  :config
  ;; Key binding for modes you want edit
  ;; or simply bind ‘global-map’ for all.
  (define-key prog-mode-map        (kbd "C-c '") #'separedit)
  (define-key minibuffer-local-map (kbd "C-c '") #'separedit)
  (define-key help-mode-map        (kbd "C-c '") #'separedit)
  ;; (define-key helpful-mode-map     (kbd "C-c '") #'separedit)
  ;; Default major-mode for edit buffer
  ;; can also be other mode e.g. ‘org-mode’.
  (setq separedit-default-mode 'markdown-mode)
  ;; Feature options
  ;; (setq separedit-preserve-string-indentation t)
  ;; (setq separedit-continue-fill-column t)
  ;; (setq separedit-write-file-when-execute-save t)
  ;; (setq separedit-remove-trailing-spaces-in-comment t)
  )

;; -------- undo-tree --------
(use-package undo-tree
  :defer t
  :diminish undo-tree-mode
  :hook
  ((after-init) . global-undo-tree-mode)
  :config
  (setq undo-tree-visualizer-diff t
        ;; undo-tree-auto-save-history t
        undo-tree-enable-undo-in-region nil
        ;; Increase undo-limits by a factor of ten to avoid emacs prematurely
        ;; truncating the undo history and corrupting the tree. See
        ;; https://github.com/syl20bnr/spacemacs/issues/12110
        undo-limit 800000
        undo-strong-limit 12000000
        undo-outer-limit 120000000
        ;; undo-tree-history-directory-alist
        ;; `(("." . ,(concat doom-cache-dir "undo-tree-hist/")))
        )
  :bind
  (:map undo-tree-map
        ("M-_" . nil)))

;; ;; -------- wucuo to instead flyspell --------
;; (use-package wucuo
;;   :ensure t
;;   :diminish wucuo-mode
;;   :config
;;   (add-hook 'prog-mode-hook 'wucuo-start)
;;   (setq wucuo-spell-check-buffer-predicate
;;         (lambda ()
;;           (not (memq major-mode
;;                      '(dired-mode
;;                        log-edit-mode
;;                        compilation-mode
;;                        help-mode
;;                        profiler-report-mode
;;                        speedbar-mode
;;                        gud-mode
;;                        calc-mode
;;                        Info-mode))))))

(provide '+contents)
